[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
chmod() Change File Permission Setting
#include <io.h>
#include <sys\stat.h>
int chmod(pathname, pmode);
const char *pathname; Name of file
int pmode; Permission setting
chmod() changes the permission setting of the file specified by
'pathname'. The permission setting controls whether the file has
read-only or read and write access. To change the permission setting,
set the 'pmode' value to:
S_IWRITE for write permission
S_IREAD for read permission
S_IREAD | S_IWRITE for read and write permission
Returns: 0, if successful. On error, -1 is returned and
'errno' is set to ENOENT (file not found), or EACCES
(permission denied).
Notes: Under MS-DOS all files are readable; you cannot have
a write-only file. If write permission is not
specified, the file is made read-only.
-------------------------------- Example ---------------------------------
The following statements change the file to read-only status:
#include <sys\stat.h>
#include <io.h>
int result;
main()
{
result = chmod("invoice.bak", S_IREAD);
if (result == -1)
perror("can't change permission mode");
}
See Also:
access()
creat()
fstat()
open()
stat()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson